<?php

class Formata{
	
	public static function formataDao($tabela, $coluna, $valor, $descricao){
			$conexao = Conexao::Conecta();
			$retorno = "";
			$sql = 'select '.$descricao.' from '.$tabela.' where '.$coluna.'='.$valor;
		if (!($stmt = $conexao->prepare($sql))) {
  			echo "Falha no stmt (Formata.formataDao): (" . $conexao->errorCode . ") ";  			
  			 print_r($stmt->errorInfo());
		}	
			
		if (!$stmt->execute()) {
   			 echo "Erro ao executar(Formata.formataDao): (" . $conexao->errorCode() . ") ";
   			  print_r($stmt->errorInfo());
		}
		
			while ($linha = $stmt->fetchObject()) {
				$retorno = $linha->$descricao;
	 	   }

	 	   $conexao=null;
			return $retorno;
	}
	
}


?>